<?php

namespace App\Admin\Forms;


use App\Admin\Renderable\GoodsRenderable;
use App\Models\SwtEmployee;
use App\Models\SwtGood;
use App\Models\SwtGoodQuantity;
use Dcat\Admin\Contracts\LazyRenderable;
use Dcat\Admin\Form as NestedForm;
use Dcat\Admin\Traits\LazyWidget;
use Dcat\Admin\Widgets\Form;
use Illuminate\Support\Facades\DB;

class EmployeeDetailForm extends Form implements LazyRenderable
{
    use LazyWidget;

    public function form()
    {
        $this->text('name','员工姓名');
        $this->text('contact','联系方式');
        $this->select('type','员工身份')->options([1=>'采购员',2=>'补货员']);
        $this->disableSubmitButton();
        $this->disableResetButton();
    }


    public function default(){
        $id = $this->payload['id'] ?? null;
        $employee_info = SwtEmployee::where('id', $id)->first();
        return [
            'name' => $employee_info->name,
            'contact' => $employee_info->contact,
            'type' => $employee_info->type,
        ];
    }
}
